package com.example.tse.rbyair.PKmy.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.example.tse.rbyair.PKmy.CouponActivity;
import com.example.tse.rbyair.R;
import com.example.tse.rbyair.dialog.CheckCallDialog;
import com.example.tse.rbyair.login.LoginActivity;

import org.kymjs.kjframe.log.L;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by tse on 2015/11/25.
 */
@SuppressLint("ValidFragment")
public class MeFragment extends Fragment {


    @Bind(R.id.topTitleLeftTxt)
    TextView topTitleLeftTxt;
    @Bind(R.id.backLayout)
    LinearLayout backLayout;
    @Bind(R.id.topTitleTxt)
    TextView topTitleTxt;
    @Bind(R.id.titleLayout)
    LinearLayout titleLayout;
    @Bind(R.id.btn_settings)
    TextView btnSettings;
    @Bind(R.id.titleRightLayout)
    LinearLayout titleRightLayout;
    @Bind(R.id.topTitleLayout)
    LinearLayout topTitleLayout;
    @Bind(R.id.right_login_head)
    ImageView rightLoginHead;
    @Bind(R.id.sex_icon)
    ImageView sexIcon;
    @Bind(R.id.login_name)
    TextView loginName;
    @Bind(R.id.imgBackground)
    RelativeLayout imgBackground;
    @Bind(R.id.myAllOrderImg)
    ImageView myAllOrderImg;
    @Bind(R.id.myAllOrderLayout)
    RelativeLayout myAllOrderLayout;
    @Bind(R.id.img4)
    ImageView img4;
    @Bind(R.id.waitpayLayout)
    RelativeLayout waitpayLayout;
    @Bind(R.id.img2)
    ImageView img2;
    @Bind(R.id.waiteSendLayout)
    RelativeLayout waiteSendLayout;
    @Bind(R.id.img3)
    ImageView img3;
    @Bind(R.id.waiteRecieveLayout)
    RelativeLayout waiteRecieveLayout;
    @Bind(R.id.phoneImg)
    ImageView phoneImg;
    @Bind(R.id.tv_service_phone)
    TextView tvServicePhone;
    @Bind(R.id.btn_service_phone)
    ImageView btnServicePhone;
    @Bind(R.id.tel_layout)
    RelativeLayout telLayout;
    @Bind(R.id.tv_collection)
    TextView tvCollection;
    @Bind(R.id.textView2)
    TextView textView2;
    @Bind(R.id.point)
    ImageView point;
    @Bind(R.id.couponsLayout)
    RelativeLayout couponsLayout;
    @Bind(R.id.collectionLayout)
    RelativeLayout collectionLayout;
    @Bind(R.id.inputInvitationCode)
    RelativeLayout inputInvitationCode;
    @Bind(R.id.myaddressLayout)
    RelativeLayout myaddressLayout;
    @Bind(R.id.layoutOne)
    LinearLayout layoutOne;
    @Bind(R.id.surveyLayout)
    RelativeLayout surveyLayout;
    @Bind(R.id.feedback)
    RelativeLayout feedback;
    @Bind(R.id.my_history)
    RelativeLayout myHistory;
    @Bind(R.id.messagelayout)
    RelativeLayout messagelayout;
    @Bind(R.id.layoutTwo)
    LinearLayout layoutTwo;
    @Bind(R.id.personScrollView)
    ScrollView personScrollView;

    public MeFragment() {

    }


    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        L.d("HomeFragment: onCreate:");


    }

    @Override
    public void setMenuVisibility(boolean menuVisible) {
        super.setMenuVisibility(menuVisible);
        if (this.getView() != null) {
            this.getView().setVisibility(menuVisible ? View.VISIBLE : View.GONE);
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.main_me_fragment, null);
        ButterKnife.bind(this, view);

        rightLoginHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                startActivity(new Intent(getActivity(), LoginActivity.class));


            }
        });
        topTitleTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ((MainActivity)getActivity()).goMe();
            }
        });


//        GoodsGetListRequest goodRequrs=new GoodsGetListRequest() {
//            @Override
//            public String giveType() {
//                return null;
//            }
//
//            @Override
//            public String giveBrandId() {
//                return "aaa";
//            }
//
//            @Override
//            public String giveLastest() {
//                return null;
//            }
//
//            @Override
//            public String giveHotest() {
//                return null;
//            }
//
//            @Override
//            public String giveSale() {
//                return null;
//            }
//
//            @Override
//            public String givePrice() {
//                return null;
//            }
//
//            @Override
//            public String giveCatId() {
//                return "";
//            }
//        };
//
//
//        RemoteServiceFactory.getInstance().getGoodsService(getActivity()).getList(goodRequrs, new RemoteServiceListenerT<GoodsGetListResponse>() {
//
//            @Override
//            public void PreStart() {
//                super.PreStart();
//            }
//
//            @Override
//            public void okData(GoodsGetListResponse goodsGetListResponse, int fromWhere) {
//                super.okData(goodsGetListResponse, fromWhere);
//
//
//
//            }
//
//            @Override
//            public void Finish() {
//                super.Finish();
//            }
//
//            @Override
//            public void failue(int errorNo, String strMsg) {
//                super.failue(errorNo, strMsg);
//            }
//
//            @Override
//            public void onMessage(String message) {
//                super.onMessage(message);
//            }
//
//            @Override
//            public void ok(GoodsGetListResponse goodsGetListResponse) {
//                super.ok(goodsGetListResponse);
//            }
//
//
//        });
//
//
        telLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                CheckCallDialog checkCallDialog = new CheckCallDialog();
                checkCallDialog.setOnOkClickLitener(new CheckCallDialog.OnOkClickLitener() {
                    @Override
                    public void OK() {
                        L.d("lc", "MeFragment OK:");
                        Intent intent = new Intent(Intent.ACTION_CALL,
                                Uri.parse("tel:021-96928978"));
                        startActivity(intent);
                    }

                    @Override
                    public void Cancel() {
                        L.d("lichun", "MeFragment Cancel:");
                    }
                });

                checkCallDialog.show(getFragmentManager(), "");


//                startActivity(new Intent(getActivity(),));
            }
        });

        couponsLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), CouponActivity.class));
            }
        });

        return view;
    }


    @Override
    public void onDestroy() {
        super.onDestroy();

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
